"""
认证相关Schemas
"""
from typing import Optional, Dict, Any
from pydantic import Field, EmailStr

from app.schemas.base import BaseSchema


class TokenData(BaseSchema):
    """Token数据"""
    user_id: Optional[int] = None
    username: Optional[str] = None
    role: Optional[str] = None


class UserLogin(BaseSchema):
    """用户登录"""
    username: str = Field(..., description="用户名", min_length=3, max_length=50)
    password: str = Field(..., description="密码", min_length=6, max_length=50)


class UserRegister(BaseSchema):
    """用户注册"""
    username: str = Field(..., description="用户名", min_length=3, max_length=50)
    password: str = Field(..., description="密码", min_length=6, max_length=50)
    email: Optional[str] = Field(None, description="邮箱")
    phone: Optional[str] = Field(None, description="手机号")


class TokenResponse(BaseSchema):
    """Token响应"""
    success: bool = True
    access_token: str = Field(..., description="访问令牌")
    token_type: str = Field(default="bearer", description="令牌类型")
    user: Dict[str, Any] = Field(..., description="用户信息")


class UserResponse(BaseSchema):
    """用户响应"""
    success: bool = True
    message: str = Field(..., description="响应消息")
    user: Dict[str, Any] = Field(..., description="用户信息")


class RefreshTokenRequest(BaseSchema):
    """刷新Token请求"""
    refresh_token: str = Field(..., description="刷新令牌")


class LogoutRequest(BaseSchema):
    """登出请求"""
    refresh_token: Optional[str] = Field(None, description="刷新令牌")







